package com.lzhsite.leetcode.algoritom.practise.linked;

import com.lzhsite.leetcode.algoritom.dataStruct.DLNode;

public class 打印有序链表公共部分 {

	public static void main(String[] args) {
		
		DLNode node1= new DLNode();
		DLNode node2= new DLNode();
		LinkListCommon.init(node1, node2);
		
		printCommon(node1,node2);
		
	}
	
	public static void printCommon(DLNode head1, DLNode head2){
		
		while (head1!=null && head2!=null) {
 
			if((int)head1.element<(int)head2.element){
				head1 = head1.next;
			}else if((int)head1.element>(int)head2.element){
				head2 = head2.next;
			}else if(head1.element.equals(head2.element)){
				System.out.print(head1.element+" ");
				head1 = head1.next;
				head2 = head2.next;
			
			}
			
		}
		System.out.println();
		
		
	}
}
